<template>
  <div>
    <el-cascader v-if="!disabled" :value="value" :options="options" :clearable="clearable" />
    <div v-else>{{ valueStr }}</div>
  </div>
</template>
<script>
export default {
  props: {
    value: {
      type: String,
      default: ''
    },
    disabled: {
      type: Boolean,
      default: () => false
    },
    placeholder: {
      type: String,
      default: ''
    },
    clearable: {
      type: Boolean,
      default: false
    },
    size: {
      type: String,
      default: 'small'
    },
    options: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      valueStr: ''
    }
  },
  watch: {
    value: {
      handler(val) {
        if (typeof val === 'object') {
          this.valueStr = val.join('-')
        } else {
          this.valueStr = val
        }
      },
      deep: true,
      immediate: true
    }
  },
  methods: {
    input(e) {
      this.$emit('input', e.target.value)
    }
  }
}
</script>
